home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_08
/
plauger
/
isxlong.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-09
|
569b
|
28 lines
-------------------------- Listing 6: long integer extractor ---------
// isxlong -- istream::operator>>(long&)
#include <errno.h>
#include <stdlib.h>
#include <istream>
istream& istream::operator>>(long& lo)
{ // extract a long
_TRY_IO_BEGIN
if (!ipfx())
setstate(failbit);
else
{ // gather characters and convert
char ac[_MAX_INT_DIG];
char *ep;
errno = 0;
const long x = strtol(ac, &ep, _Getifld(ac));
if (ep == ac || errno != 0)
setstate(failbit);
else
lo = x;
}
isfx();
_CATCH_IO_END
return (*this);
}